package de.rs.espresso.tools.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import de.rs.espresso.interfaces.ICover;
import de.rs.espresso.interfaces.IGlobalInformation;
import de.rs.espresso.tools.gui.model.KVModel;

public class KVDrawer extends JFrame {
	
	private KVModel kVModel;

	private JPanel contentPane;

	/**
	 * Launch the application.
	 * @param title 
	 */
	public static void draw(final ICover cover, final IGlobalInformation info, final String title) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					for(int i = 0; i<info.getNumberOfOutputs() ; i++) {
						KVDrawer frame = new KVDrawer(new KVModel(cover,info,i,title), title);
						frame.setVisible(true);
					}

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 * @param kvModel 
	 * @param title 
	 */
	public KVDrawer(KVModel kvModel, String title) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 700, 700);
		setTitle(title);
		contentPane = new KVDrawPanel(kvModel);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
	}

}
